home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / SCREEN / CURSES01 / minix / c / refresh < prev    next >
Text File  |  1991-05-05  |  4KB  |  109 lines

  1. /****************************************************************/
  2. /* Wrefresh() and wnoutrefresh() routines of the PCcurses    */
  3. /* package                            */
  4. /*                                */
  5. /****************************************************************/
  6. /* This version of curses is based on ncurses, a curses version    */
  7. /* originally written by Pavel Curtis at Cornell University.    */
  8. /* I have made substantial changes to make it run on IBM PC's,    */
  9. /* and therefore consider myself free to make it public domain.    */
  10. /*        Bjorn Larsson (...mcvax!enea!infovax!bl)    */
  11. /****************************************************************/
  12. /* 1.0:    Release:                    870515    */
  13. /****************************************************************/
  14. /* Modified to run under the MINIX operating system by Don Cope */
  15. /* These changes are also released into the public domain.      */
  16. /*                             900906  */
  17. /****************************************************************/
  18.  
  19. #include <curses.h>
  20. #include "curspriv.h"
  21.  
  22. /****************************************************************/
  23. /* Wrefresh() updates window win's area of the physical screen.    */
  24. /****************************************************************/
  25.  
  26. void wrefresh(win)
  27.   WINDOW    *win;
  28.   {
  29.   if (win == curscr)
  30.     curscr->_clear = TRUE;
  31.   else
  32.     wnoutrefresh(win);
  33.   doupdate();
  34.   } /* wrefresh */
  35.  
  36. /****************************************************************/
  37. /* Wnoutrefresh() updates the image of the desired screen,    */
  38. /* without doing physical update (copies window win's image to    */
  39. /* the _cursvar.tmpwin window, which is hidden from the user).    */
  40. /****************************************************************/
  41.  
  42. void wnoutrefresh(win)
  43.   register WINDOW    *win;
  44.   {
  45.   register int      *dst;            /* start destination in temp window */
  46.   register int    *end;            /* end destination in temp window */
  47.   register int    *src;            /* source in user window */
  48.   register int     first;        /* first changed char on line */
  49.   register int     last;        /* last changed char on line */
  50.   static   WINDOW *nscr;
  51.   static   int       begy;        /* window's place on screen */
  52.   static   int       begx;
  53.   static   int       i;
  54.   static   int       j;
  55.  
  56.   nscr = _cursvar.tmpwin;
  57.   begy = win->_begy;
  58.   begx = win->_begx;
  59.   nscr->_colors = win->_colors;
  60.  
  61.   for (i=0, j=begy; i <= win->_maxy; i++, j++)
  62.     {
  63.     if (win->_minchng[i] != _NO_CHANGE)
  64.       {
  65.       first = win->_minchng[i];
  66.       last  = win->_maxchng[i];
  67.       dst   = &(nscr->_line[j][begx + first]);
  68.       end   = &(nscr->_line[j][begx + last]);
  69.       src   = &(win->_line[i][first]);
  70.  
  71.       while (dst <= end)         /* copy user line to temp window */
  72.     *dst++ = *src++;
  73.  
  74.       first += begx;            /* nscr's min/max change positions */
  75.       last  += begx;
  76.  
  77.       if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
  78.     nscr->_minchng[j] = first;
  79.       if (last > nscr->_maxchng[j])
  80.     nscr->_maxchng[j] = last;
  81.       
  82.       win->_minchng[i] = _NO_CHANGE;    /* updated now */
  83.       } /* if */
  84.     win->_maxchng[i] = _NO_CHANGE;    /* updated now */
  85.     } /* for */
  86.  
  87.   if (win->_clear)
  88.     {
  89.     win->_clear = FALSE;
  90.     nscr->_clear = TRUE;
  91.     } /* if */
  92.  
  93.   if (!win->_leave)
  94.     {
  95.     nscr->_cury = win->_cury + begy;
  96.     nscr->_curx = win->_curx + begx;
  97.     } /* if */
  98.   } /* wnoutrefresh */
  99.  
  100. /****************************************************************/
  101. /* Refresh() updates stdscr's area of the physical screen.    */
  102. /****************************************************************/
  103.  
  104. void refresh()
  105.   {
  106.   wrefresh(stdscr);
  107.   wrefresh(curscr);
  108.   } /* refresh */
  109.